package com.markyao.service.raft;

import com.markyao.aop.annotations.BroadcastCheck;
import com.markyao.vo.ConfParam;
import com.markyao.vo.ConfigInfoVo;
import com.markyao.vo.pojo.ConfigInfo;
import org.checkerframework.checker.units.qual.C;
import org.springframework.stereotype.Component;

@BroadcastCheck
@Component
public class BroadcastConfigInfoService extends BroadcastService{
    private final String routeInsertConfigInfo="/recos/group/insertConfigInfo";
    private final String routeDeleteConfigInfo="/recos/group/deleteConfigInfo";
    private final String routeDeleteConfigInfos="/recos/group/deleteConfigInfos";
    private final String routeUpdateConfigInfo="/recos/group/updateConfigInfo";
    private final String routeRollback="/recos/group/rollback";
    private final String routeDeleteHisConfig="/recos/group/deleteHisConfig";
    private final String routeRefreshOk="/recos/group/refreshOk";
    private final String routeRefreshConf="/recos/group/refreshConf";
    private final String routeRegistDataIdAndAppName="/recos/group/registDataIdAndAppName";


    public boolean insertConfigInfo(ConfigInfoVo configInfo) {
        String route=routeInsertConfigInfo;
        boolean insertConfigInfo = generalBroadcastPost(route, "insertConfigInfo", configInfo);
        return insertConfigInfo;
    }

    public boolean deleteConfigInfo(Long id) {
        String route=routeDeleteConfigInfo+"/"+id;
        return generalBroadcast(route, "deleteConfigInfo");
    }

    public boolean deleteConfigInfos(String[] ids) {
        String route=routeDeleteConfigInfos;
        return generalBroadcastPost(route, "deleteConfigInfos", ids);
    }

    public boolean updateConfigInfo(ConfigInfoVo configInfov) {
        String route=routeUpdateConfigInfo;
        return generalBroadcastPost(route,"updateConfigInfo",configInfov);
    }

    public boolean rollback(String id) {
        String route=routeRollback+"/"+id;
        return generalBroadcast(route,"rollback");
    }

    public boolean deleteHisConfig(String[] ids) {
        String route=routeDeleteHisConfig;
        return generalBroadcastPost(route, "deleteHisConfig", ids);
    }

    public boolean refreshOk(String appName) {
        String route=routeRefreshOk+"/"+appName;
        return generalBroadcast(route,"refreshOk");
    }

    public boolean refreshConf(ConfParam conf) {
        String route=routeRefreshConf;
        return generalBroadcastPost(route, "refreshConf", conf);

    }

    public boolean registDataIdAndAppName(String appName, String dataId) {
        String route=routeRegistDataIdAndAppName+"/"+appName+"/"+dataId;
        return generalBroadcast(route,"registDataIdAndAppName");
    }
}
